<!DOCTYPE html>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<%--
  Created by IntelliJ IDEA.
  User: 85167
  Date: 2017/12/10
  Time: 11:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <c:import url="/WEB-INF/page/header.jsp"/>
</head>
<body>
<div class="col-md-12">
    <input id="devId" type="hidden" name="id" value="${info.id}">
    <table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
        <tbody>
        <tr>
            <td class="width-15 "><label class="pull-right"><font color="red">*</font>设备ID：</label></td>
            <td>
                ${info.id}
            </td>
            <td class=""><label class="pull-right"><font color="red">*</font>设备状态：</label></td>
            <td>
                <c:choose>
                    <c:when test="${info.devStatus eq 0}">
                        备用
                    </c:when>
                    <c:when test="${info.devStatus eq 1}">
                        待激活
                    </c:when>
                    <c:when test="${info.devStatus eq 2}">
                        出厂测试状态
                    </c:when>
                    <c:when test="${info.devStatus eq 3}">
                        正常制水
                    </c:when>
                    <c:when test="${info.devStatus eq 4}">
                        欠费
                    </c:when>
                    <c:when test="${info.devStatus eq 5}">
                        故障
                    </c:when>
                    <c:when test="${info.devStatus eq 6}">
                        关机
                    </c:when>
                    <c:when test="${info.devStatus eq 7}">
                        水满
                    </c:when>
                    <c:when test="${info.devStatus eq 8}">
                        缺水
                    </c:when>
                    <c:when test="${info.devStatus eq 9}">
                        漏水
                    </c:when>
                    <c:when test="${info.devStatus eq 10}">
                        滤芯待复位
                    </c:when>
                    <c:when test="${info.devStatus eq 11}">
                        硬件测试
                    </c:when>
                    <c:otherwise>
                        未知
                    </c:otherwise>
                </c:choose>
            </td>

            <td class=""><label class="pull-right"><font color="red">*</font>剩余流量：</label></td>
            <td>
                ${info.remainFlow}
            </td>
        </tr>
        <tr>
            <td class=""><label class="pull-right"><font color="red">*</font>已用流量：</label></td>
            <td>
                ${info.usedFlow}
            </td>

            <td class=""><label class="pull-right"><font color="red">*</font>剩余天数：</label></td>
            <td>
                ${info.remainTime}
            </td>
            <td class="w"><label class="pull-right"><font color="red">*</font>已用天数：</label></td>
            <td>
                ${info.usedTime}
            </td>
        </tr>
        <tr>
            <td class=""><label class="pull-right"><font color="red">*</font>净水TDS：</label></td>
            <td>
                ${info.rawTds}
            </td>
            <td class=""><label class="pull-right"><font color="red">*</font>原水TDS：</label></td>
            <td>
                ${info.purityTds}
            </td>
            <td class="w"><label class="pull-right"><font color="red">*</font>安装时间：</label></td>
            <td>
                <fmt:formatDate value="${info.bindTime}" pattern="yyyy-MM-dd"/>
            </td>
        </tr>
        <tr>
            <td class="w"><label class="pull-right"><font color="red">*</font>工作模式：</label></td>
            <td>
                <c:choose>
                    <c:when test="${info.billTypeId eq 0}">
                        流量
                    </c:when>
                    <c:when test="${info.billTypeId eq 1}">
                        时长
                    </c:when>
                    <c:otherwise>
                        买断
                    </c:otherwise>
                </c:choose>
            </td>
            <td class="w"><label class="pull-right"><font color="red">*</font>地址：</label></td>
            <td>
                ${info.address}
            </td>
            <td class="w"><label class="pull-right"><font color="red">*</font>绑定状态：</label></td>
            <td>
                <c:if test="${info.bindStatus eq 1}">已经绑定</c:if>
                <c:if test="${info.bindStatus eq 0}">未绑定</c:if>
            </td>
        </tr>
        </tbody>
    </table>
    <table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
        <tbody>
        <tr>
            <td class=""><label class="pull-right"><font color="red">*</font>模式转换：</label></td>
            <td>
                <select id="billType" class="form-control">
                    <c:choose>
                        <c:when test="${info.billTypeId eq 0}">
                            <option value="1">时长</option>
                            <option value="2">买断</option>
                        </c:when>
                        <c:when test="${info.billTypeId eq 1}">
                            <option value="0">流量</option>
                            <option value="2">买断</option>
                        </c:when>
                        <c:otherwise>
                        </c:otherwise>
                    </c:choose>
                </select>
                <br/>
                <div class="input-group m-b">
                    <span class="input-group-addon">转换系数(升/天):</span>
                    <input id="ll2sc" type="text" class="form-control" value="${devSet.ll2sc}">
                </div>
            </td>
            <td colspan="2" style="text-align: left">
                <button class="btn btn-success" onclick="switchModel()">确认提交模式转换</button>
            </td>
        </tr>
        <tr>
            <td class="w"><label class="pull-right"><font color="red">*</font>断网情况下泵工作时间(分钟)：</label></td>
            <td>
                <input id="dwbgzsj" value="${devSet.pumpWorkTime}" type="text" name="" class="form-control  number">
            </td>
            <td colspan="2" style="text-align: left">
                <button class="btn btn-success" onclick="read(2,'dwbgzsj')">读取</button>
                <button class="btn btn-success" onclick="chgDwbgzsj()">确认提交断网情况下泵工作时间</button>
            </td>
        </tr>
        <tr>
            <td class="w"><label class="pull-right"><font color="red">*</font>强制冲洗时间(秒)：</label></td>
            <td>
                <input id="qzcxsj" value="${devSet.washTime}" type="text" name="" class="form-control required number">
            </td>
            <td colspan="2" style="text-align: left">
                <button class="btn btn-success" onclick="read(3,'qzcxsj')">读取</button>
                <button class="btn btn-success" onclick="chgQzcxsj()">确认提交强制冲洗时间</button>
            </td>
        </tr>
        <tr>
            <td class="w"><label class="pull-right"><font color="red">*</font>定时冲洗时间(分钟)：</label></td>
            <td>
                <input id="dscxsj" value="${devSet.washFixedTime}" type="text" name=""
                       class="form-control required number">
            </td>
            <td colspan="2" style="text-align: left">
                <button class="btn btn-success" onclick="read(4,'dscxsj')">读取</button>
                <button class="btn btn-success" onclick="chgDscxsj()">确认提交定时冲洗时间</button>
            </td>
        </tr>
        <tr>
            <td class="w"><label class="pull-right"><font color="red">*</font>检修时长(分钟)：</label></td>
            <td>
                <input id="jxsc" value="${devSet.serviceTime}" type="text" name="" class="form-control required number">
            </td>
            <td colspan="2" style="text-align: left">
                <button class="btn btn-success" onclick="read(5,'jxsc')">读取</button>
                <button class="btn btn-success" onclick="chgJxsc()">确认提交检修时长</button>
            </td>
        </tr>
        <tr>
            <td class="w"><label class="pull-right"><font color="red">*</font>制1升水需要的时间(分钟)：</label></td>
            <td>
                <input id="oneWaterOfTime" value="${devSet.oneWaterOfTime}" type="text" name=""
                       class="form-control required number">
            </td>
            <td colspan="2" style="text-align: left">
                <button class="btn btn-success" onclick="read(6,'oneWaterOfTime')">读取</button>
                <button class="btn btn-success" onclick="chgOneWaterOfTime()">确认提交制1升水需要的时间</button>
            </td>
        </tr>
        </tbody>
    </table>
    <table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
        <tbody>
        <c:forEach items="${filters}" var="vo">
            <tr>
                <td style="width: 100px;"><label class="pull-right"><font
                        color="red">*</font>${vo.filterInfo.name}：</label></td>
                <td class="width-35">
                    <a href="#" onclick="filterInit('${vo.id}')">
                            ${vo.maxValue-vo.used}/${vo.maxValue}
                    </a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<c:import url="/WEB-INF/page/footer.jsp"/>
<script>
    function filterInit(id) {
        swal({
            title: "确认恢复滤芯吗？(请注意，需要执行30秒！)",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            closeOnConfirm: false
        }, function () {
            doChgStatus(base + "/admin/biz/devInfo/filterInit/" + id);
        });
    }

    function switchModel() {
        var params = "";
        var devId = $("#devId").val();
        params = params + "devId=" + devId;

        var billType = $("#billType").val();
        if (billType) {
            params = params + "&billType=" + billType;
        } else {
            swal("模式必须选择");
            return;
        }

        var ll2sc = $("#ll2sc").val();
        if (ll2sc) {
            params = params + "&ll2sc=" + ll2sc;
        } else {
            swal("转换系数必须设置");
            return;
        }
        swal({
            title: "确认模式切换吗？(请注意，需要执行30秒！)",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            closeOnConfirm: false
        }, function () {

            doChgStatus(base + "/admin/biz/devInfo/switchModel?" + params);
        });
    }

    function chgDwbgzsj() {
        var params = "";
        var devId = $("#devId").val();
        params = params + "devId=" + devId;
        var dwbgzsj = $("#dwbgzsj").val();
        if (dwbgzsj) {
            params = params + "&dwbgzsj=" + dwbgzsj;
        } else {
            swal("断网工作泵时长必须设置");
            return;
        }
        swal({
            title: "确认修改断网泵工作时长？(请注意，需要执行30秒！)",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            closeOnConfirm: false
        }, function () {

            doChgStatus(base + "/admin/biz/devInfo/switchModel?" + params);
        });
    }

    function chgQzcxsj() {
        var params = "";
        var devId = $("#devId").val();
        params = params + "devId=" + devId;
        var qzcxsj = $("#qzcxsj").val();
        if (qzcxsj) {
            params = params + "&qzcxsj=" + qzcxsj;
        } else {
            swal("强制冲洗时间必须设置");
            return;
        }
        swal({
            title: "确认修改强制冲洗时间？(请注意，需要执行30秒！)",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            closeOnConfirm: false
        }, function () {

            doChgStatus(base + "/admin/biz/devInfo/switchModel?" + params);
        });
    }

    function chgDscxsj() {
        var params = "";
        var devId = $("#devId").val();
        params = params + "devId=" + devId;
        var dscxsj = $("#dscxsj").val();
        if (dscxsj) {
            params = params + "&dscxsj=" + dscxsj;
        } else {
            swal("定时冲洗时间必须设置");
            return;
        }
        swal({
            title: "确认修改定时冲洗时间？(请注意，需要执行30秒！)",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            closeOnConfirm: false
        }, function () {

            doChgStatus(base + "/admin/biz/devInfo/switchModel?" + params);
        });
    }

    function chgJxsc() {
        var params = "";
        var devId = $("#devId").val();
        params = params + "devId=" + devId;
        var jxsc = $("#jxsc").val();
        if (jxsc) {
            params = params + "&jxsc=" + jxsc;
        } else {
            swal("设备检修时长必须设置");
            return;
        }
        swal({
            title: "确认修改检修时长吗？(请注意，需要执行30秒！)",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            closeOnConfirm: false
        }, function () {

            doChgStatus(base + "/admin/biz/devInfo/switchModel?" + params);
        });
    }
    function chgOneWaterOfTime() {
        var params = "";
        var devId = $("#devId").val();
        params = params + "devId=" + devId;
        var oneWaterOfTime = $("#oneWaterOfTime").val();
        if (oneWaterOfTime) {
            params = params + "&oneWaterOfTime=" + oneWaterOfTime;
        } else {
            swal("设备检修时长必须设置");
            return;
        }
        swal({
            title: "制1升水需要的时间？(请注意，需要执行30秒！)",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            closeOnConfirm: false
        }, function () {

            doChgStatus(base + "/admin/biz/devInfo/switchModel?" + params);
        });
    }

    function read(type, dom) {
        $.ajax({
            url: base + "/admin/biz/devInfo/read/" + $("#devId").val() + "/" + type,
            dataType: "json",
            success: function (data) {
                if (data.code == 0) {
                    swal("读取成功！", "", "success");
                    setTimeout(function () {
                        this.location.reload();
                    }, 3000);

                    //$("#" + dom).val(data.data);
                } else {
                    swal("读取失败！设备不在线", "error");
                }
            },
            error: function (data) {
                swal("更新失败！", "系统错误", "error");
            }
        });
    }

</script>
</body>
</html>
